<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/common/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title>添加用户</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="<%=path %>/layui/css/layui.css">
  <link rel="stylesheet" href="<%=path %>/layui/css/lxq.css">
	<script type="text/javascript" src="<%=path %>/layui/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="<%=path %>/layui/layui.js" charset="utf-8"></script>
</head>
<body>
<div class="lxq-body">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>修改用户</legend>
</fieldset>
 <form class="layui-form"  method="post" id="data_form">
  <div class="layui-row layui-col-space10">

		<div class="layui-form-item">
		    <label class="layui-form-label">角色</label>
		    <div class="layui-input-block">
		      <input type="radio" name="userType" value="0" title="学生" checked>
		      <input type="radio" name="userType" value="1" title="教师">
		      <input type="radio" name="userType" value="9" title="管理员" >
		    </div>
		  </div>
		
		<div class="layui-form-item">
		    <label class="layui-form-label">所属学院</label>
		    <div class="layui-input-block">
		     <select id="userAcademy" name="userAcademy" lay-filter="userAcademy" lay-search>
			</select>     
		    </div>
		  </div>
		  
		<div class="layui-form-item">
		    <label class="layui-form-label">所属专业</label>
		    <div class="layui-input-block">
		     <select id="userMajor" name="userMajor" lay-filter="userMajor" lay-search>
			</select>     
		    </div>
		  </div>
		  
		 <div class="layui-form-item">
		    <label class="layui-form-label">所属班级</label>
		    <div class="layui-input-block">
		     <select id="userClass" name="userClass" lay-filter="userClass" lay-search>
			</select>     
		    </div>
		  </div>
		  
		 <div class="layui-form-item">
		    <label class="layui-form-label">所属部门</label>
		    <div class="layui-input-block">
		     <select id="userUnit" name="userUnit" lay-filter="userUnit" lay-search>
			</select>     
		    </div>
		  </div>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">ID</label>
		    <div class="layui-input-block">
		      <input type="text" name="userId" required  lay-verify="required" placeholder="请输班级名" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">密码</label>
		    <div class="layui-input-block">
		      <input type="text" name="userPassword" required  lay-verify="required" placeholder="请输班级名" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  
		  
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">姓名</label>
		    <div class="layui-input-block">
		      <input type="text" name="userName" required  lay-verify="required" placeholder="请输班级名" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		
		  <div class="layui-form-item">
		    <label class="layui-form-label">性别</label>
		    <div class="layui-input-block">
				<input type="checkbox" name="userSex" lay-skin="switch" lay-text="发布|关闭">
			</div>
		  </div>
		  
		   
	     <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">手机</label>
		    <div class="layui-input-block">
		      <input type="text" name="userPhone" required  lay-verify="required" placeholder="请输班级名" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">电子邮箱</label>
		    <div class="layui-input-block">
		      <input type="text" name="userEmail" required  lay-verify="required" placeholder="请输班级名" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  
		  
	    <div class="layui-form-item">
		    <div class="layui-input-block">
		    <button class="layui-btn" lay-submit lay-filter="submit">立即提交</button> 
		    </div>
		  </div>
		

    
    
  
  </div>    
          
</form>
 </div>
<script>
layui.use(['form'], function(){
  var form = layui.form;
  var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  var academyId = "${info.infoParent}";
  var majorId = "${info.id}";


  
  getAcademy();
  getMajor(academyId);



  form.on('select(academys)', function(data){
	  getMajor(data.value);
	});    
  
  
  function getAcademy(){
	  $.ajax({
			type:"post",
			url:"<%=basePath%>/biz/Info_getList",
			data:{level : "1"},
			success:function(data){
				$("#academys").find("option").remove();
				for(var i = 0; i < data.length; i++){
					if(academyId == data[i].id){
						$("#academys").append("<option value='"+data[i].id+"' selected>"+data[i].infoName+"</option>");
					}else{
						$("#academys").append("<option value='"+data[i].id+"'>"+data[i].infoName+"</option>");
					}
					
				}
				form.render('select');
				
			}
	  })
  }
  
  
  function getMajor(parent){
	  $.ajax({
			type:"post",
			url:"<%=basePath%>/biz/Info_getList",
			data:{level : "2" , infoParent : parent},
			success:function(data){
				$("#majors").find("option").remove();
				for(var i = 0; i < data.length; i++){
					if(majorId == data[i].id){
						$("#majors").append("<option value='"+data[i].id+"' selected>"+data[i].infoName+"</option>");
					}else{
						$("#majors").append("<option value='"+data[i].id+"'>"+data[i].infoName+"</option>");
					}
					
				}
				form.render('select');
				
			}
	  })
  }
  
  form.on('submit(submit)', function(data){
		$.ajax({
			type:"POST",
			url:"<%=basePath%>/biz/Info_add",
			data:data.field,
			success:function(data){
				 parent.layer.close(index); //再执行关闭
			}
		});
	  return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
	});
  
  

});
</script>

</body>
</html>